package com.maori.languageapp.curatephrase;

import java.util.ArrayList;
import java.util.HashMap;

import com.maori.languageapp.R;
import com.maori.languageapp.consts.ImageLoader;
import com.maori.languageapp.curateword.Maori_Curate_Word_Details;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class Maori_Curate_Phrase_Details_Adapter extends BaseAdapter {
	private static final String TAG = null;
	// Declare Variables
	Context context;
	LayoutInflater inflater;
	ArrayList<HashMap<String, String>> data;
	ImageLoader imageLoader;
	Button curate_approve,curate_reject,curate_modify;
	HashMap<String, String> resultp = new HashMap<String, String>();
	
	public Maori_Curate_Phrase_Details_Adapter(Context context,
			ArrayList<HashMap<String, String>> arraylist) {
		this.context = context;
		data = arraylist;
		imageLoader = new ImageLoader(context);

	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		// Declare Variables
		TextView maori_synonym_title, english_synonym_title,first_name,last_name;
		ImageView flag; // Loading User Images (Future use)
		Button dicover_example_country,Discover_example_likes;
		Button setDefAction,setLikeAction;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View itemView = inflater.inflate(R.layout.languageapp_curate_synonyms,
				parent, false);
		
		// Get the position from the results
		resultp = data.get(position);
		//flag = (ImageView) itemView.findViewById(R.id.mem_discover_img);

		//Display Synonyms
		maori_synonym_title = (TextView) itemView.findViewById(R.id.maori_synonym_title);
		english_synonym_title= (TextView) itemView.findViewById(R.id.english_synonym_title);
		dicover_example_country= (Button) itemView.findViewById(R.id.dicover_example_country);
		first_name= (TextView) itemView.findViewById(R.id.first_name);
		last_name= (TextView) itemView.findViewById(R.id.last_name);
		flag = (ImageView) itemView.findViewById(R.id.imggriditem);
		
		curate_approve = (Button) itemView.findViewById(R.id.curate_approve);
		curate_reject = (Button) itemView.findViewById(R.id.curate_reject);
		curate_modify = (Button) itemView.findViewById(R.id.curate_modify);
		
		// Capture position and set results to the TextViews
		maori_synonym_title.setText(resultp.get(Maori_Curate_Phrase_Details.Description_a));
		english_synonym_title.setText(resultp.get(Maori_Curate_Phrase_Details.Description_b));
		dicover_example_country.setText(resultp.get(Maori_Curate_Phrase_Details.tribeuser));
		first_name.setText(resultp.get(Maori_Curate_Phrase_Details.first_namesuser));
		last_name.setText(resultp.get(Maori_Curate_Phrase_Details.last_nameuser));
		
		
		imageLoader.DisplayImage(resultp.get(Maori_Curate_Phrase_Details.userimageuser), flag);
		curate_approve.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Log.e("PRINT 1", " :" + resultp.get(Maori_Curate_Phrase_Details.SYNNID));
				Log.e("PRINT 1", " :" + resultp.get(Maori_Curate_Phrase_Details.UIDuser));
			}
		});
		
		curate_reject.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Log.e("PRINT 2", " :" + resultp.get(Maori_Curate_Phrase_Details.SYNNID));
				Log.e("PRINT 2", " :" + resultp.get(Maori_Curate_Phrase_Details.UIDuser));
			}
		});
		
		curate_modify.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Log.e("PRINT 3", " :" + resultp.get(Maori_Curate_Phrase_Details.SYNNID));
				Log.e("PRINT 3", " :" + resultp.get(Maori_Curate_Phrase_Details.UIDuser));
			}
		});
		
		imageLoader.DisplayImage(resultp.get(Maori_Curate_Phrase_Details.userimageuser),
				flag);
	
		return itemView;
	}
}
